/**
 * 版权所有（c）2021. 上海海鼎信息工程股份有限公司，保留所有权利
 */
package com.lovely602.design.structure.decorator.demo;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.io.InputStream;

/**
 * 具体构件角色：原身
 *
 * @author lizhixing
 */
public class Original extends JFrame implements Morrigan {
  private String t = "Morrigan0.jpg";

  public Original() {
    super("《恶魔战士》中的莫莉卡·安斯兰");
  }

  public void setImage(String t) {
    this.t = t;
  }

  @Override
  public void display() {
    this.setLayout(new FlowLayout());

    try {
      InputStream is = ClassLoader.getSystemResourceAsStream("image/" + t);
      Image image = ImageIO.read(is);
      JLabel l1 = new JLabel(new ImageIcon(image));
      this.add(l1);
      this.pack();
      this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      this.setVisible(true);
    } catch (IOException e) {
      e.printStackTrace();
    }

  }
}
